import fitz  # PyMuPDF

# 存放pdf路径
pdf_document = "xiaoliu.pdf"
pdf_file = fitz.open(pdf_document)
pdf_name = pdf_document.split('.', 1)[0]

# 设置缩放比例（例如 3.0 表示 300% 的清晰度）
scale = 3.0
matrix = fitz.Matrix(scale, scale)

i = 1
for page_number in range(len(pdf_file)):
    page = pdf_file.load_page(page_number)
    pix = page.get_pixmap(matrix=matrix)  # 使用矩阵调整分辨率
    pix.save(f"page_{pdf_name}_{page_number + 1}.png")
    print(f"第{i}张图片转换成功")
    i = i + 1

pdf_file.close()